package com.athuiju.fenxiaoback.service.impl;

import com.athuiju.fenxiaoback.entity.UmsMemberReceiveAddress;
import com.athuiju.fenxiaoback.entity.vo.MemberAddressVo;
import com.athuiju.fenxiaoback.mapper.UmsMemberReceiveAddressMapper;
import com.athuiju.fenxiaoback.service.UmsMemberReceiveAddressService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 会员收货地址 服务实现类
 * </p>
 *
 * @author athuiju
 * @since 2021-07-06
 */
@Service
public class UmsMemberReceiveAddressServiceImpl extends ServiceImpl<UmsMemberReceiveAddressMapper, UmsMemberReceiveAddress> implements UmsMemberReceiveAddressService {
    @Override
    public List<UmsMemberReceiveAddress> getAddress(String memberid) {

        List<UmsMemberReceiveAddress> addresses = this.list(new QueryWrapper<UmsMemberReceiveAddress>().eq("member_id", memberid));
        return addresses;

    }

    @Override
    public boolean updateDefault(Long addressId,boolean isDefault) {
        QueryWrapper<UmsMemberReceiveAddress> wrapper=new QueryWrapper<>();
        wrapper.eq("id",addressId);
        UmsMemberReceiveAddress address = this.getOne(wrapper);
        address.setDefaultStatus(isDefault);
        boolean update = this.update(address, wrapper);
        return update;
    }


}
